package operatori;

import Interpretor.Context;

public class Ori extends Operator {

	public String concatTermeni(String aux1, String aux2) {
		return ConcatTermeni(aux1, aux2);

	}

	public static String ConcatTermeni(String aux1, String aux2) {
		if ((aux1.compareTo("0") == 0) || (aux2.compareTo("0") == 0))
			return "0";
		if (aux1.compareTo("1") == 0)
			return aux2;
		if (aux2.compareTo("1") == 0)
			return aux1;
		if (aux1.charAt(0) == '-')
			if (aux2.charAt(0) == '-')
				return aux1.substring(1) + "*" + aux2.substring(1);
			else
				return aux1 + "*" + aux2;
		else if (aux2.charAt(0) == '-')
			return "-" + aux1 + "*" + aux2.substring(1);

		if (aux1.equals(aux2))
			return aux1 + "^2";
		return aux1 + "*" + aux2;

	}
	public void interpret(Context cont) {
		cont.actual(this);
	}
	/*
	public double calcul(double aux1, double aux2) {
		return aux1 * aux2;
	}

	public static double Calcul(double aux1, double aux2) {
		return aux1 * aux2;
	}

	public double calculDerivata() {
		// TODO Auto-generated method stub
		if ((fStang == null) || (fDrept == null))
			System.exit(1);

		return Plus.Calcul(calcul(fStang.calculDerivata(), fDrept.calcul()),
				calcul(fStang.calcul(), fDrept.calculDerivata()));
	}

	public String derivare() {
		// TODO Auto-generated method stub
		if ((fStang == null) || (fDrept == null))
			System.exit(1);
		return Plus.ConcatTermeni(concatTermeni(fStang.derivare(), fDrept
				.toString()), concatTermeni(fStang.toString(), fDrept
				.derivare()));
	}
	*/
}
